package com.carolouvindam.Model;

import java.util.Date;
import java.util.List;

public class Order {
    private Long idDB;
    private Client client;
    private Address address;
    private List<Product> produits;
    private Date date;
    private Integer tempsMiddle = 5;
    private Integer tempsLarge = 10;

    public Order(Long idDB, Client client, Address address, List<Product> produits, Date date) {
        this.idDB = idDB;
        this.client = client;
        this.address = address;
        this.produits = produits;
        this.date = date;
    }

    public OrderPriority getPriority() {
        if (TimeElapsed() < 1*60*1000) {
            return (OrderPriority.VLow);
        }

        if (TimeElapsed() < 3*60*1000) {
            return (OrderPriority.Low);
        }

        if (TimeElapsed() < 10*60*1000) {
            return (OrderPriority.Normal);
        }

        if (TimeElapsed() < 15*60*1000) {
            return (OrderPriority.High);
        }

        return (OrderPriority.VHigh);

    }

    public Long TimeElapsed() {

        Date now = new Date();
        return (now.getTime() - this.getDate().getTime());
        

    }


    public Client getClient() {
        return client;
    }

    public void setClient(Client client) {
        this.client = client;
    }

    public Address getAddress() {
        return address;
    }

    public void setAddress(Address address) {
        this.address = address;
    }

    public List<Product> getProduits() {
        return produits;
    }

    public void setProduits(List<Product> produits) {
        this.produits = produits;
    }

    public Date getDate() {
        return date;
    }

    public void setDate(Date date) {
        this.date = date;
    }

    public Long getIdDB() {
        return idDB;
    }

    public void setIdDB(long idDB) {
        this.idDB = idDB;
    }

}
